package apollo.generator.common.exception;

import apollo.generator.common.base.IBaseResponseCode;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * <Description>
 * 自定义异常
 * @author Jun Lee
 * @version 1.0
 * @createDate 2020-03-27 18:15:36
 */
@Data
@AllArgsConstructor
public class CustomException extends Exception {

    private Integer code = IBaseResponseCode.ERROR_CODE;

    public CustomException(String message) {
        super(message);
    }

    public static Exception throwException(String message) throws Exception {
        throw new Exception(message);
    }

    public static Exception throwCustomException(String message) throws CustomException {
        throw new CustomException(message);
    }

    public static Exception throwCustomException(String message,Integer code) throws CustomException {
        CustomException exception = new CustomException(message);
        throw exception;
    }
}
